// 3396. 使数组元素互不相同所需的最少操作次数
// AC: https://leetcode.cn/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/submissions/620187820/

class Solution {
public:
    int minimumOperations(vector<int>& nums) {
        set<int> s;
        for(int i=nums.size()-1;i>=0;--i){
            if(s.find(nums[i])!=s.end()){
                return (i+3)/3;
            }
            s.insert(nums[i]);
        }
        return 0;
    }
};